home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg3.cab / master_chapter_numbering.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  8KB  |  174 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: master_chapter_numbering.xsl,v $
  7.  
  8.     $Revision: 1.5 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:08:50 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <!--
  37.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  38. -->
  39. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  40.         xmlns:office="http://openoffice.org/2000/office"
  41.         xmlns:style="http://openoffice.org/2000/style"
  42.         xmlns:text="http://openoffice.org/2000/text"
  43.         xmlns:table="http://openoffice.org/2000/table"
  44.         xmlns:draw="http://openoffice.org/2000/drawing"
  45.         xmlns:fo="http://www.w3.org/1999/XSL/Format"
  46.         xmlns:xlink="http://www.w3.org/1999/xlink"
  47.         xmlns:number="http://openoffice.org/2000/datastyle"
  48.         xmlns:svg="http://www.w3.org/2000/svg"
  49.         xmlns:chart="http://openoffice.org/2000/chart"
  50.         xmlns:dr3d="http://openoffice.org/2000/dr3d"
  51.         xmlns:math="http://www.w3.org/1998/Math/MathML"
  52.         xmlns:form="http://openoffice.org/2000/form"
  53.         xmlns:script="http://openoffice.org/2000/script"
  54.         xmlns:dc="http://purl.org/dc/elements/1.1/"
  55.         xmlns:meta="http://openoffice.org/2000/meta"
  56.         xmlns:config="http://openoffice.org/2001/config"
  57.         xmlns:help="http://openoffice.org/2000/help"
  58.         xmlns:sxg="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoMasterDocument"
  59.         xmlns:java="http://xml.apache.org/xslt/java"
  60.         xmlns="http://www.w3.org/1999/xhtml"
  61.         version="1.0"
  62.         exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help java sxg">
  63.  
  64.  
  65.     <!-- ************************** -->
  66.     <!-- *** Chapter Numbering  *** -->
  67.     <!-- ************************** -->
  68.  
  69.  
  70.     <!-- The chapter number of the current document (child of a master document) is dependent of the amount
  71.          of chapters of the same level in preceding documents (preceding children of the master document). -->
  72.     <xsl:param name="precedingChapterLevel1" select="0" />
  73.     <xsl:param name="precedingChapterLevel2" select="0" />
  74.     <xsl:param name="precedingChapterLevel3" select="0" />
  75.     <xsl:param name="precedingChapterLevel4" select="0" />
  76.     <xsl:param name="precedingChapterLevel5" select="0" />
  77.     <xsl:param name="precedingChapterLevel6" select="0" />
  78.     <xsl:param name="precedingChapterLevel7" select="0" />
  79.     <xsl:param name="precedingChapterLevel8" select="0" />
  80.     <xsl:param name="precedingChapterLevel9" select="0" />
  81.     <xsl:param name="precedingChapterLevel10" select="0" />
  82.  
  83.     <!-- Office documents containing a table of contents,
  84.         gonna link for usability reason above each chapter to the preceding and following document and the content table -->
  85.     <xsl:param name="contentTableURL" />
  86.  
  87.  
  88.     <xsl:template name="get-heading-number">
  89.         <xsl:param name="globalData" />
  90.         <xsl:param name="precedingChapterLevel1" />
  91.  
  92.         <xsl:choose>
  93.             <xsl:when test="$currentChildContentRef">
  94.                 <xsl:variable name="currentFileHeadingNo">
  95.                     <xsl:call-template name="get-current-file-heading-no" />
  96.                 </xsl:variable>
  97.                 <xsl:variable name="testResult" select="$contentTableHeadings/heading[$currentChildContentRef = @file-url][number($currentFileHeadingNo)]" />
  98.                 <xsl:call-template name="get-global-heading-no">
  99.                     <xsl:with-param name="currentFileHeadingNo" select="translate($testResult/@absolute-chapter-level, '_', '.')" />
  100.                     <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1" />
  101.                 </xsl:call-template>
  102.             </xsl:when>
  103.             <xsl:otherwise>
  104.                 <!-- When the chapter is in the master document itself the link has to be relative (e.g. #index) a absolute href does not
  105.                     work with the browser. In case of chapter in the master document, the output URL of the master document was taken. -->
  106.                 <xsl:variable name="currentFileHeadingNo">
  107.                     <xsl:call-template name="get-current-file-heading-no" />
  108.                 </xsl:variable>
  109.                 <xsl:variable name="testResult" select="$globalData/content-table-headings/heading[$contentTableURL = @file-url][number($currentFileHeadingNo)]" />
  110.  
  111.                 <xsl:call-template name="get-global-heading-no">
  112.                     <xsl:with-param name="currentFileHeadingNo" select="translate($testResult/@absolute-chapter-level, '_', '.')" />
  113.                     <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1" />
  114.                 </xsl:call-template>
  115.             </xsl:otherwise>
  116.         </xsl:choose>
  117.  
  118.         <!-- Note: Two white-space as default indent after heading number,
  119.                    Currently @style:num-suffix will be neglected -->
  120.         <xsl:text>  </xsl:text>
  121.     </xsl:template>
  122.  
  123.  
  124.     <xsl:template name="get-current-file-heading-no">
  125.         <xsl:choose>
  126.             <xsl:when test="function-available('sxg:get-current-child-heading-no')">
  127.                 <xsl:value-of select="sxg:get-current-child-heading-no()" />
  128.             </xsl:when>
  129.             <xsl:when test="function-available('java:org.openoffice.xslt.OOoMasterDocument.getCurrentChildHeadingNo')">
  130.                 <xsl:value-of select="java:org.openoffice.xslt.OOoMasterDocument.getCurrentChildHeadingNo()" />
  131.             </xsl:when>
  132.             <xsl:otherwise>
  133.                 <xsl:message terminate="yes">ERROR: Function not found: java:org.openoffice.xslt.OOoMasterDocument.getCurrentChildHeadingNo()</xsl:message>
  134.             </xsl:otherwise>
  135.         </xsl:choose>
  136.     </xsl:template>
  137.  
  138.  
  139.  
  140.     <xsl:template name="get-global-heading-no">
  141.         <xsl:param name="currentFileHeadingNo" />
  142.         <xsl:param name="precedingChapterLevel1" />
  143.  
  144.         <xsl:choose>
  145.             <xsl:when test="function-available('sxg:get-global-heading-no')">
  146.                 <xsl:value-of select="sxg:get-global-heading-no(string($currentFileHeadingNo), number($precedingChapterLevel1))" />
  147.             </xsl:when>
  148.             <xsl:when test="function-available('java:org.openoffice.xslt.OOoMasterDocument.getGlobalHeadingNo')">
  149.                 <xsl:value-of select="java:org.openoffice.xslt.OOoMasterDocument.getGlobalHeadingNo(string($currentFileHeadingNo), number($precedingChapterLevel1))" />
  150.             </xsl:when>
  151.             <xsl:otherwise>
  152.                 <xsl:message terminate="yes">ERROR: Function not found: java:org.openoffice.xslt.OOoMasterDocument.getGlobalHeadingNo</xsl:message>
  153.             </xsl:otherwise>
  154.         </xsl:choose>
  155.     </xsl:template>
  156.  
  157.  
  158.  
  159.     <xsl:template name="get-next-current-file-heading-no">
  160.         <xsl:param name="file" />
  161.         <xsl:choose>
  162.             <xsl:when test="function-available('sxg:get-next-current-child-heading-no')">
  163.                 <xsl:value-of select="sxg:get-next-current-child-heading-no($file)" />
  164.             </xsl:when>
  165.             <xsl:when test="function-available('java:org.openoffice.xslt.OOoMasterDocument.getNextCurrentChildHeadingNo')">
  166.                 <xsl:value-of select="java:org.openoffice.xslt.OOoMasterDocument.getNextCurrentChildHeadingNo($file)" />
  167.             </xsl:when>
  168.             <xsl:otherwise>
  169.                 <xsl:message terminate="yes">ERROR: Function not found: java:org.openoffice.xslt.OOoMasterDocument.getNextCurrentChildHeadingNo</xsl:message>
  170.             </xsl:otherwise>
  171.         </xsl:choose>
  172.     </xsl:template>
  173.  
  174. </xsl:stylesheet>